package com.sqsf.util;

import com.sqsf.factory.StaticFactory;
import org.junit.Test;

public class MyTest {
    @Test
    public void staticFactory(){
        StaticFactory s1=null;
        //s1=new StaticFactory();//没有提供任何构造方法 不能通过new关键字创建对象
        s1=StaticFactory.get();//可以通过静态方法获取对象
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Object staticFactory = applicationContext.getBean("staticFactory");
        System.out.println(staticFactory);
        applicationContext.close();
    }

    @Test
    public void test(){
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Object u1 = applicationContext.getBean("u1");
        System.out.println(u1);
        applicationContext.close();
    }
}
